package com.SmartCare.controller.client;

import com.SmartCare.common.Result;
import com.SmartCare.service.CallNoteService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/alarms")
@Api(tags = "C端通话提醒相关接口")
@Slf4j
public class ReminderController {
    @Resource
    private CallNoteService callNoteService;

    /**
     * 查询通话提醒记录
     */
    @GetMapping("/query")
    public Result query(Long userId){
        return callNoteService.queryAll(userId);
    }
    /**
     * 添加通话提醒记录
     */
    @GetMapping("/add")
    public Result addAlarm(@RequestParam Long userId,
                           @RequestParam(required = false,defaultValue = "0") int second,
                           @RequestParam(required = false,defaultValue = "0") int minute,
                           @RequestParam int hour,
                           @RequestParam(required = false,defaultValue = "?") String dayOfMonth,
                           @RequestParam(required = false,defaultValue = "*") String month,
                           @RequestParam int dayOfWeek, // 1表示周日，2表示周一，以此类推
                           @RequestParam(required = false,defaultValue = "") String reminderContent,
                           @RequestParam(required = false,defaultValue = "1") int status) {
        return  callNoteService.addAlarm(userId,second,minute,hour,dayOfWeek,month,dayOfMonth,reminderContent,status);
    }

    /**
     * 删除通话提醒记录
     */
    @GetMapping("/delete")
    public Result delete(@RequestParam List<Long> ids) {
        return callNoteService.delete(ids);
    }

    /**
     * 更新通话提醒记录
     */
    @GetMapping("/update")
    public Result update(@RequestParam Long id,
                         @RequestParam(required = false,defaultValue = "0") int second,
                         @RequestParam(required = false,defaultValue = "0") int minute,
                         @RequestParam(required = false) Integer hour,
                         @RequestParam(required = false,defaultValue = "?") String dayOfMonth,
                         @RequestParam(required = false,defaultValue = "*") String month,
                         @RequestParam(required = false) String reminderContent,
                         @RequestParam(required = false) Integer dayOfWeek, // 1表示周日，2表示周一，以此类推
                         @RequestParam(required = false,defaultValue = "1") Integer status
                        ) {
        return callNoteService.updateData(id,second,minute,hour,dayOfMonth,month,dayOfWeek,reminderContent,status);
    }

}
